package com.atcumt.bytedance;

import java.util.Scanner;

public class Main {

    /**
     * 2
     * 44 85
     * 9 49
     * 
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int t = scanner.nextInt();
        while (scanner.hasNext()) {
            long x = scanner.nextLong();
            long y = scanner.nextLong();
            long min1 = Math.min(y, (x + y) / 3);
            long min2 = Math.min(x, min1);
            long count = x - min2 + (y - min2);
            long res = Math.min(min2, count);
            System.out.println(res);
        }
    }
}
